CISC
1110 Lab 4
Write a program which will read values into two
variables named realnum and val, print the values, divide each value by 2, and
then print out the results.
First, declare three variables. The variables named realnum and ans can hold values with decimal places, and the variable named val can’t hold decimal places.
Next, write a
prompt asking the user to type in an odd value (like 3 or 7 or -15).
Read that value
into realnum.
Then write a
prompt asking the user to type another odd value.
Read that value into val.
Now do
computation: Divide realnum by 2, assign the
result to ans, and send ans
to cout, together with an identifying message.
Then divide val by 2, assign the result to ans, and send ans to cout together with an identifying message.
Why are the
results different?
Now run the
program again (without changing any code) and enter two even numbers.
Do NOT change
the program and do NOT recompile the program. Just re-run the program and read
in different values.